package blog

import (
	"dustbe/database"
	"net/http"
	"strconv"

	"github.com/gin-gonic/gin"
)

func SimpleRecommand(c *gin.Context) {
	blogName := c.Query("blogName")
	RecNum, err := strconv.Atoi(c.Query("RecNum"))
	if err != nil {
		RecNum = 3
	}

	blogs, err := database.RecommandByBlogName(blogName, RecNum)
	if err != nil {
		c.JSON(http.StatusOK, gin.H{"code" : 4006, "msg" : err.Error()})
		return
	}
	c.JSON(http.StatusOK, gin.H{"code" : 200, "data" : blogs})
}